package cn.sczhyt.modules.szhy.service.impl;

import cn.sczhyt.modules.szhy.dao.MeetingScheduleDao;
import cn.sczhyt.modules.szhy.entity.MeetingEntity;
import cn.sczhyt.modules.szhy.service.MeetingService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.sczhyt.common.utils.PageUtils;
import cn.sczhyt.modules.szhy.entity.MeetingScheduleEntity;
import cn.sczhyt.modules.szhy.service.MeetingScheduleService;


@Service("meetingScheduleService")
public class MeetingScheduleServiceImpl extends ServiceImpl<MeetingScheduleDao, MeetingScheduleEntity> implements MeetingScheduleService {


    @Autowired
    private MeetingService meetingService;

    @Override
    public List<MeetingScheduleEntity> getByMeetingId(String meetingId) {
        QueryWrapper<MeetingScheduleEntity> wrapper = new QueryWrapper<MeetingScheduleEntity>()
                                                        .eq("meeting_id", meetingId)
                                                        .orderByAsc("schedule_start_time");
        List<MeetingScheduleEntity> MeetingScheduleEntities = baseMapper.selectList(wrapper);

        MeetingEntity meetingEntity = meetingService.getById(meetingId);

        if (meetingEntity == null) {
            return null;
        }

        List<MeetingScheduleEntity> collect = MeetingScheduleEntities.stream().map(entity -> {
            entity.setMeetingName(meetingEntity.getMeetingName());
            return entity;
        }).collect(Collectors.toList());

        return collect;

    }

    @Override
    public PageUtils listAll() {
        return null;
    }
}